<template>
  <div class="kaochangguanli flex">
    <left></left>
    <div style="width: calc(100vw - 280px); height: calc(100vh - 40px); overflow: auto; padding: 20px;">

      <!--        <div>平台共计收益：100</div>

        <div>平台分销商收益：100</div>

        <div>平台共计打款：100</div> -->

      <div>
        <div style="margin-bottom: 20px; font-size: 16px; font-weight: bold;">用户多次刷广告奖金限制</div>

        <div v-for="(item,index) in peizhi" :key="index" style="margin-bottom: 10px;">
          第<el-input v-model="item.code" style="width: 150px; margin: 0 20px; " placeholder="次数"></el-input>
          次刷广告得一份奖金的的百分之
          <el-input v-model="item.value" style="width: 150px; margin: 0 20px; " placeholder="百分比"></el-input>
        </div>

        <el-button type="primary" round @click="add">增加规则</el-button>

        <el-button type="primary" round @click="fabu">保存规则</el-button>
      </div>


      <div style="margin: 20px 0;">
        邀请新用户给<el-input v-model="fenxiao.inv_user_income" style="width: 150px; margin: 0 20px; "
          placeholder="人民币"></el-input>元/人，
        新人必须分销<el-input v-model="fenxiao.enough_income" style="width: 150px; margin: 0 20px; "
          placeholder="人民币"></el-input>元才给。


      </div>

      <el-button type="primary" round @click="fabu2">保存规则</el-button>


    </div>
  </div>
</template>

<script>
  import left from '../left.vue'
  export default {
    name: 'kaochangguanli',
    components: {
      left
    },
    data() {
      return {
        peizhi: [],
        fenxiao: {
          inv_user_income: "",
          enough_income: ""
        }
      }
    },
    created() {


      axios.get(this.IP_URL + '/admin/sys/incomelist').then((response) => {
        if (response.data.msg.code == 0) {
          this.peizhi = response.data.data
        } else {
          this.$message.error(response.data.msg.info);
        }
      })

      axios.get(this.IP_URL + '/admin/sys/incomeinvlist').then((response) => {
        if (response.data.msg.code == 0) {
          this.fenxiao = response.data.data
        } else {
          this.$message.error(response.data.msg.info);
        }
      })



    },
    mounted() {

    },
    methods: {
      fabu2: function() {
        axios.post(this.IP_URL + '/admin/sys/incomeinvlist', this.fenxiao).then((response) => {
          if (response.data.msg.code == 0) {
            this.$message.success('保存成功');
          } else {
            this.$message.error(response.data.msg.info);
          }
        })
      },

      add: function() {
        this.peizhi.push({
          code: "",
          value: ""
        })
      },

      fabu: function() {
        axios.post(this.IP_URL + '/admin/sys/incomesave', {
          datas: this.peizhi
        }).then((response) => {
          if (response.data.msg.code == 0) {
            this.$message.success('保存成功');
          } else {
            this.$message.error(response.data.msg.info);
          }
        })

      }
    }
  }
</script>


<style scoped>

</style>
